<?php
class Search_model{
    public $con;
    public function __construct(){
        $this->con =  mysqli_connect(DB_HOST,DB_USER,DB_PASSWORD,DB_NAME);
        if(mysqli_connect_error())
        {
            echo "Failed to connect to MySQL". mysqli_connect_error();exit();
        }
    }
    function search($keyword,$category){
        $sql = "SELECT * FROM fileupload WHERE filename LIKE '%$keyword%' AND id_catfile = $category";
        $result = mysqli_query($this->con,$sql);
        return $result;
    }
    function searchs($keyword){
        $sql = "SELECT * FROM fileupload WHERE filename LIKE '%$keyword%'";
        $result = mysqli_query($this->con,$sql);
        return $result;
    }
}